package com.java.comprehensive.arithmetic.programmers;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @program: comprehensive-service
 * @description: 回文排列
 * @author: 窦绍飞
 * @create: 2022-01-20 14:27
 **/
public class CanPermutePalindrome {

	public static boolean canPermutePalindrome(String s) {

		char[] chars = s.toCharArray();

		Set<Character> characters = new HashSet<>();
		for (int i = 0; i < chars.length; i++) {

			if (characters.contains(chars[i])) {
				characters.remove(chars[i]);
			} else {
				characters.add(chars[i]);
			}
		}


		return characters.size() <= 1;
	}

	public static void main(String[] args) {

		String str = "aab";
		System.out.println(canPermutePalindrome(str));

	}

}